package CollectionsFramework.Iterator;

import java.util.ArrayList;
import java.util.concurrent.CountDownLatch;

public class Test {
    public static void main(String[] args) throws InterruptedException {
        final ArrayList<Integer> list = new ArrayList<>();
        CountDownLatch countDownLatch = new CountDownLatch(200);
        for (int i = 0; i < 20000; i++) {
            new Thread(()->{
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                list.add(1);
                countDownLatch.countDown();
            }).start();
        }
        countDownLatch.await();
        System.out.println(list.size());
    }
}
